// packageD/pages/distribution/index/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        withdrawableAmount: 1000.00, // 可提现佣金
        totalCommission: 10099.00,   // 累计佣金
        withdrawnAmount: 9000.00,    // 已提现
        frozenAmount: 99,             // 冻结佣金
        zvisible: false,
        QRcode: null,
        DistributorM: null,
        CommissionTotal: {
            accumulatedIncomeAmount: 99.18,
            freeze: 0,
            newcustomersTodaycount: 388,
            newcustomerscount: 62,
            newordersTodaycount: 50,
            neworderscount: 10,
            pending: 66.18,
            todayamount: 77,
            withdrawable: 88.18,
            withdrawn: 6000,
        }
    },
    clickshuju(e) {
        wx.navigateTo({
            url: '/packageD/pages/commission/index',
        })
    },
    //获取分销员数据
    GetDistributorManagement() {
        return wx.Http.post("/DistributorManagementAppService/GetDistributorManagement", {});
    },
    //获取分销记录统计
    GetCommissionTotal() {
        return wx.Http.post("/CommissionAppService/GetCommissionTotal", {});
    },
    withdraw() {
        wx.navigateTo({
            url: '/packageD/pages/withdraw/index',
        })
    },
    bindvisible(event) {
        console.log(event)
        wx.navigateTo({
            url: event.currentTarget.dataset.url,
        })
        this.setData({
            zvisible: !this.data.zvisible
        })
    },
    bindPreview(e) {
        let sources = [];
        let obj = {};
        obj.url = this.data.QRcode;
        obj.type = 'image';
        sources.push(obj);
        wx.previewMedia({
            sources: sources,
            current: 0,
            fail: function () {
                wx.showToast({ title: '预览失败', icon: 'none' });
            },
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        // let userinfo = wx.getStorageSync('Monkey');
        // if (userinfo.wxaCodeUnlimitUrl) {
        //     this.setData({
        //         QRcode: userinfo.wxaCodeUnlimitUrl
        //     })
        // } else {
        //     wx.removeStorage({
        //         key: 'Monkey',
        //     })
        //     wx.Http.post("/AccountAppService/GetUserinfo", {}).then((res) => {
        //         if (res.data.value) {
        //             wx.setStorageSync("Monkey", res.data.value);
        //             this.setData({
        //                 QRcode: res.data.value.wxaCodeUnlimitUrl
        //             })
        //         }
        //     });
        // }
        // this.GetDistributorManagement().then((res) => {
        //     console.log(res.data)
        //     if (res.data) {
        //         this.setData({
        //             DistributorM: res.data
        //         })
        //     }
        // });
        // this.GetCommissionTotal().then((res) => {
        //     if (res.data.value) {
        //         console.log(res.data.value)
        //         this.setData({
        //             CommissionTotal: res.data.value
        //         })
        //     }
        // });
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})